﻿@using DevExtreme.NETCore.Demos.Models

@model IEnumerable<Order>

@(Html.DevExtreme().DataGrid<Order>()
    .ID("gridContainer")
    .DataSource(Model, "ID")
    .RepaintChangesOnly(true)
    .ShowBorders(true)
    .Editing(e => e
        .Mode(GridEditMode.Batch)
        .AllowAdding(true)
        .AllowUpdating(true)
        .AllowDeleting(true)
    )
    .Columns(columns => {
        columns.AddFor(m => m.OrderNumber)
            .Width(130);

        columns.AddFor(m => m.OrderDate);

        columns.AddFor(m => m.Employee);

        columns.AddFor(m => m.CustomerStoreCity);

        columns.AddFor(m => m.CustomerStoreState);

        columns.AddFor(m => m.SaleAmount)
            .Alignment(HorizontalAlignment.Right)
            .Format(Format.Currency)
            .EditorOptions(new { format = "currency" });
    })
    .Summary(s => s
        .RecalculateWhileEditing(true)
        .TotalItems(items => {
            items.AddFor(m => m.OrderNumber)
                .SummaryType(SummaryType.Count);

            items.AddFor(m => m.SaleAmount)
                .SummaryType(SummaryType.Sum)
                .ValueFormat(Format.Currency);
        })
    )
)
